#This is the main CMAKE for build all components.

set(ISO8859MAPS
    ${CMAKE_CURRENT_SOURCE_DIR}/iso8859_2_to_utf8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_iso8859_2.map
    ${CMAKE_CURRENT_SOURCE_DIR}/iso8859_3_to_utf8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_iso8859_3.map
    ${CMAKE_CURRENT_SOURCE_DIR}/iso8859_4_to_utf8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_iso8859_4.map
    ${CMAKE_CURRENT_SOURCE_DIR}/iso8859_5_to_utf8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_iso8859_5.map
    ${CMAKE_CURRENT_SOURCE_DIR}/iso8859_6_to_utf8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_iso8859_6.map
    ${CMAKE_CURRENT_SOURCE_DIR}/iso8859_7_to_utf8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_iso8859_7.map
    ${CMAKE_CURRENT_SOURCE_DIR}/iso8859_8_to_utf8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_iso8859_8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/iso8859_9_to_utf8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_iso8859_9.map
    ${CMAKE_CURRENT_SOURCE_DIR}/iso8859_10_to_utf8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_iso8859_10.map
    ${CMAKE_CURRENT_SOURCE_DIR}/iso8859_13_to_utf8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_iso8859_13.map
    ${CMAKE_CURRENT_SOURCE_DIR}/iso8859_14_to_utf8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_iso8859_14.map
    ${CMAKE_CURRENT_SOURCE_DIR}/iso8859_15_to_utf8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_iso8859_15.map
    ${CMAKE_CURRENT_SOURCE_DIR}/iso8859_16_to_utf8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_iso8859_16.map
)

set(WINMAPS
    ${CMAKE_CURRENT_SOURCE_DIR}/win866_to_utf8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_win866.map
    ${CMAKE_CURRENT_SOURCE_DIR}/win874_to_utf8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_win874.map
    ${CMAKE_CURRENT_SOURCE_DIR}/win1250_to_utf8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_win1250.map
    ${CMAKE_CURRENT_SOURCE_DIR}/win1251_to_utf8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_win1251.map
    ${CMAKE_CURRENT_SOURCE_DIR}/win1252_to_utf8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_win1252.map
    ${CMAKE_CURRENT_SOURCE_DIR}/win1253_to_utf8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_win1253.map
    ${CMAKE_CURRENT_SOURCE_DIR}/win1254_to_utf8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_win1254.map
    ${CMAKE_CURRENT_SOURCE_DIR}/win1255_to_utf8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_win1255.map
    ${CMAKE_CURRENT_SOURCE_DIR}/win1256_to_utf8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_win1256.map
    ${CMAKE_CURRENT_SOURCE_DIR}/win1257_to_utf8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_win1257.map
    ${CMAKE_CURRENT_SOURCE_DIR}/win1258_to_utf8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_win1258.map
)

set(GENERICMAPS
    ${ISO8859MAPS} ${WINMAPS}
    ${CMAKE_CURRENT_SOURCE_DIR}/johab_to_utf8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_johab.map
    ${CMAKE_CURRENT_SOURCE_DIR}/uhc_to_utf8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_uhc.map
    ${CMAKE_CURRENT_SOURCE_DIR}/gbk_to_utf8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_gbk.map
    ${CMAKE_CURRENT_SOURCE_DIR}/koi8r_to_utf8.map
    ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_koi8r.map
)

set(ISO8859TEXTS
    ${CMAKE_CURRENT_SOURCE_DIR}/8859-2.TXT
    ${CMAKE_CURRENT_SOURCE_DIR}/8859-3.TXT
    ${CMAKE_CURRENT_SOURCE_DIR}/8859-4.TXT
    ${CMAKE_CURRENT_SOURCE_DIR}/8859-5.TXT
    ${CMAKE_CURRENT_SOURCE_DIR}/8859-6.TXT
    ${CMAKE_CURRENT_SOURCE_DIR}/8859-7.TXT
    ${CMAKE_CURRENT_SOURCE_DIR}/8859-8.TXT
    ${CMAKE_CURRENT_SOURCE_DIR}/8859-9.TXT
    ${CMAKE_CURRENT_SOURCE_DIR}/8859-10.TXT
    ${CMAKE_CURRENT_SOURCE_DIR}/8859-13.TXT
    ${CMAKE_CURRENT_SOURCE_DIR}/8859-14.TXT
    ${CMAKE_CURRENT_SOURCE_DIR}/8859-15.TXT
    ${CMAKE_CURRENT_SOURCE_DIR}/8859-16.TXT
)

set(WINTEXTS
    ${CMAKE_CURRENT_SOURCE_DIR}/CP866.TXT
    ${CMAKE_CURRENT_SOURCE_DIR}/CP874.TXT
    ${CMAKE_CURRENT_SOURCE_DIR}/CP1250.TXT
    ${CMAKE_CURRENT_SOURCE_DIR}/CP1251.TXT
    ${CMAKE_CURRENT_SOURCE_DIR}/CP1252.TXT
    ${CMAKE_CURRENT_SOURCE_DIR}/CP1253.TXT
    ${CMAKE_CURRENT_SOURCE_DIR}/CP1254.TXT
    ${CMAKE_CURRENT_SOURCE_DIR}/CP1255.TXT
    ${CMAKE_CURRENT_SOURCE_DIR}/CP1256.TXT
    ${CMAKE_CURRENT_SOURCE_DIR}/CP1257.TXT
    ${CMAKE_CURRENT_SOURCE_DIR}/CP1258.TXT
)

set(GENERICMAPS
    ${ISO8859TEXTS} ${WINTEXTS}
    ${CMAKE_CURRENT_SOURCE_DIR}/KOI8-R.TXT
    ${CMAKE_CURRENT_SOURCE_DIR}/CP936.TXT
    ${CMAKE_CURRENT_SOURCE_DIR}/CP949.TXT
    ${CMAKE_CURRENT_SOURCE_DIR}/JOHAB.TXT
)

add_custom_command(
    OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${GENERICMAPS} 
    COMMAND perl ${CMAKE_CURRENT_SOURCE_DIR}/UCS_to_most.pl
    DEPENDS ${DEPENDS} ${CMAKE_CURRENT_SOURCE_DIR}/UCS_to_most.pl
    COMMENT "Now Generating *.map"
)

add_custom_command(
    OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/euc_jp_to_utf8.map ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_euc_jp.map 
    COMMAND perl ${CMAKE_CURRENT_SOURCE_DIR}/UCS_to_EUC_JP.pl
    DEPENDS UCS_to_EUC_JP.pl JIS0201.TXT JIS0208.TXT JIS0212.TXT
    COMMENT "Now Generating *.map"
)
add_custom_command(
    OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/euc_cn_to_utf8.map ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_euc_cn.map 
    COMMAND perl ${CMAKE_CURRENT_SOURCE_DIR}/UCS_to_EUC_CN.pl
    DEPENDS UCS_to_EUC_CN.pl GB2312.TXT
    COMMENT "Now Generating *.map"
)
add_custom_command(
    OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/euc_kr_to_utf8.map ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_euc_kr.map 
    COMMAND perl ${CMAKE_CURRENT_SOURCE_DIR}/UCS_to_EUC_KR.pl
    DEPENDS UCS_to_EUC_KR.pl KSX1001.TXT
    COMMENT "Now Generating *.map"
)
add_custom_command(
    OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/euc_tw_to_utf8.map ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_euc_tw.map 
    COMMAND perl ${CMAKE_CURRENT_SOURCE_DIR}/UCS_to_EUC_TW.pl
    DEPENDS UCS_to_EUC_TW.pl CNS11643.TXT
    COMMENT "Now Generating *.map"
)
add_custom_command(
    OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/sjis_to_utf8.map ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_sjis.map 
    COMMAND perl ${CMAKE_CURRENT_SOURCE_DIR}/UCS_to_SJIS.pl
    DEPENDS UCS_to_SJIS.pl CP932.TXT
    COMMENT "Now Generating *.map"
)
add_custom_command(
    OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/gb18030_to_utf8.map ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_gb18030.map
    COMMAND perl ${CMAKE_CURRENT_SOURCE_DIR}/UCS_to_GB18030.pl
    DEPENDS UCS_to_GB18030.pl gb-18030-2000.xml
    COMMENT "Now Generating *.map"
)

add_custom_command(
    OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/big5_to_utf8.map ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_big5.map 
    COMMAND perl ${CMAKE_CURRENT_SOURCE_DIR}/UCS_to_BIG5.pl
    DEPENDS UCS_to_BIG5.pl BIG5.TXT CP950.TXT
    COMMENT "Now Generating *.map"
)

add_custom_command(
    OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/gb18030_to_utf8_2022.map ${CMAKE_CURRENT_SOURCE_DIR}/utf8_to_gb18030_2022.map
    COMMAND perl ${CMAKE_CURRENT_SOURCE_DIR}/UCS_to_GB18030_2022.pl
    DEPENDS UCS_to_GB18030_2022.pl gb-18030-2022.xml
    COMMENT "Now Generating *.map"
)